package com.xiaoye.digitaltwin.service.impl;

import com.xiaoye.digitaltwin.entity.Waiya;
import com.xiaoye.digitaltwin.mapper.WaiyaMapper;
import com.xiaoye.digitaltwin.service.WaiyaService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 外压实验表 服务实现类
 * </p>
 *
 * @author xiaoye
 * @since 2023-04-01
 */
@Service
public class WaiyaServiceImpl extends ServiceImpl<WaiyaMapper, Waiya> implements WaiyaService {

    @Override
    public String check(Waiya waiya) {
        if(waiya.getStress() == null){
            return "压力值不能为空";
        }
        if(waiya.getLength() == null){
            return "试件长度不能为空";
        }
        if(waiya.getOuterMax() == null){
            return "外径最大值不能为空";
        }
        if(waiya.getOuterMin() == null){
            return "外径最小值不能为空";
        }
        if(waiya.getWallThick() == null){
            return "壁厚不能为空";
        }
        if(waiya.getInitDefect() == null){
            return "初始缺陷不能为空";
        }
        if(waiya.getLength() < 127.6 || waiya.getLength() > 128.0){
            return "试件长度不在规定范围";
        }
        Double outerThick = (waiya.getOuterMin() + waiya.getOuterMin()) / 2;
        if(outerThick < 52.5 || outerThick > 52.8){
            return "平均外径值不在规定范围";
        }
        if(waiya.getInitDefect() < 0.01 || waiya.getInitDefect() > 0.05){
            return "初始缺陷不在规定范围";
        }
        if(waiya.getWallThick() < 0.24 || waiya.getWallThick() > 0.26){
            return "壁厚不在规定范围";
        }

        if(waiya.getStress() <= 0 || waiya.getStress() >0.225){
            return "压力值不在规定范围";
        }

        return "通过";
    }
}
